module(..., package.seeall )

local MetaTable = {
	__index = getfenv(),
	__tostring = function( stack )
		
		local ret = ""
		
		for _, v in pairs( stack.list ) do
			ret = ret .. tostring(v) .. "->"
		end
		
		return ret
	end
}

function New()
	
	local o = {
		list = {},
		top = 0
	}
	
	setmetatable( o, MetaTable )
	
	return o
	
end

function has( self, item )
	for i=1, self.top do
		if self.list[ i ] == item then
			return true
		end
	end
	return false
end

function empty(self) 
   return (self.top == 0)
end 

function push( self, item )
	self.top = self.top+1
	self.list[self.top] = item
end

function top( self )
	return self.list[ self.top ]
end

function pop( self )
	self.top = self.top-1
	return self.list[self.top+1]
end